import urllib2

class queue_proxy(object):
    def __init__(self, url):
        self.url = url
        
    def append(self, queue_id, data):
        req = urllib2.Request(self.url + "/append/?queue_id=" + queue_id, data)
        respon = urllib2.urlopen(req)
        result = respon.read()
        return result
    
    def fetch(self, queue_id, client_id):
        req = urllib2.Request(self.url + "/fetch/?queue_id=" + queue_id + "&client_id=" + client_id)
        resp = urllib2.urlopen(req)
        result = resp.read()
        return result

    def reset_cursor(self, queue_id, client_id):
        req = urllib2.Request(self.url + "/reset_cursor/?queue_id=" + queue_id + "&client_id=" + client_id)
        resp = urllib2.urlopen(req)
        result = resp.read()
        return result

